#if !defined(QMITK_DataPositioning_H__INCLUDED)
#define QMITK_DataPositioning_H__INCLUDED

//#include "QmitkFunctionality.h"

#include <QmitkFunctionality.h>
#include <QmitkStandardViews.h>
#include <QmitkStdMultiWidgetEditor.h>

#include <mitkWeakPointer.h>

#include "ui_QmitkDataPositioningControls.h"
#include "WxPointedSticksInteractor.h"

class QmitkStdMultiWidget;
//!mm
//class QmitkDataPositioningControls;
//!

/*!
\brief

\sa QmitkFunctionality
\ingroup org_mitk_gui_qt_DataPositioning_internal
*/
class QmitkDataPositioning : public QObject, public QmitkFunctionality
{
  Q_OBJECT
public :
        class QmitkExt_EXPORT ItkEventListener : public itk::Command
        {
          public:
            mitkClassMacro(ItkEventListener, itk::Command);
            ItkEventListener(QmitkStdMultiWidget* receiver) :
              m_Receiver(receiver)
            {

            };
            virtual void 	Execute (itk::Object *  caller , const itk::EventObject & /* event */)
            {
              mitk::BaseData* data=dynamic_cast<mitk::BaseData*> (caller);
              if(data)
                m_Receiver->MoveCrossToPosition(data->GetGeometry()->GetOrigin());
            };
            virtual void 	Execute (const itk::Object *  caller , const itk::EventObject & /* event */)
            {
                const mitk::BaseData* data=dynamic_cast<const mitk::BaseData*> (caller);
                if(data)
                  m_Receiver->MoveCrossToPosition(data->GetGeometry()->GetOrigin());
            };
          protected:
            QmitkStdMultiWidget* m_Receiver;
        };

  public:
    QmitkDataPositioning();
    virtual ~QmitkDataPositioning();
    virtual void Activated();
    virtual void Deactivated();
    virtual bool IsExclusiveFunctionality() const;
    ///
    /// Called when the selection in the workbench changed
    ///
    virtual void OnSelectionChanged(std::vector<mitk::DataNode*> nodes);

    virtual void NodeRemoved(const mitk::DataNode* node);

  protected:
    // Pseudo Ctor
    void CreateQtPartControl(QWidget* parent);

  protected slots:

    void AddDistanceDataPositioning();

  protected:
    /*!
    * controls containing sliders for scrolling through the slices
    */
    Ui::QmitkDataPositioningControls * m_Controls;

    /*
     * Interactor for performing the DataPositionings.
     */
    mitk::WeakPointer<mitk::WxPointedSticksInteractor> m_PointedSticksInteractor;

     /*
      *  Node representing the PointSet last created. It is used to delete empty point sets.
     */
    std::vector<mitk::DataNode*> m_CreatedNodes;

    long m_ObserverTag;
    ItkEventListener::Pointer m_ItkEventListener;
    mitk::DataNode::Pointer m_OldData;
};

#endif // !defined(QMITK_DataPositioning_H__INCLUDED)

